home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -in_the_mag- / banging_the_metal / qdos / qdos4amiga3.lha / BEEP10_BAS < prev    next >
Text File  |  1998-02-12  |  4KB  |  137 lines

  1. 100 REMark Amiga Qdos STEREO TONE GENERATOR
  2. 110 REMark Uses 32 chip RAM bytes. Rev. 10
  3. 120 REMark By Simon N Goodwin, 18 July 1993
  4. 130 REMark Uses HEX, ALCHP and RECHP extns.
  5. 140 :
  6. 150 REMark Pentatonic musical constants
  7. 160 root=2^(1/53)
  8. 170 note2=root^9
  9. 180 note3=root^17
  10. 190 note4=root^31
  11. 200 note5=root^39
  12. 210 DIM note%(39)
  13. 220 here=28800:REMark Or 25920, or 32767
  14. 230 FOR i=39 TO 4 STEP -5
  15. 240   note%(i)=here
  16. 250   note%(i-1)=here/note2
  17. 260   note%(i-2)=here/note3
  18. 270   note%(i-3)=here/note4
  19. 280   note%(i-4)=here/note5
  20. 290   here=here/2
  21. 300 END FOR i
  22. 310 :
  23. 320 REMark Limit of chip RAM
  24. 330 chip_top=2^21
  25. 340 REMark Hardware register labels
  26. 350 pra    =HEX("BFE001")
  27. 360 DMACONx=HEX("DFF096")
  28. 370 adkcon =HEX("DFF09E")
  29. 380 aud0lc =HEX("DFF0A0")
  30. 390 aud0len=aud0lc+4
  31. 400 aud0per=aud0lc+6
  32. 410 aud0vol=aud0lc+8
  33. 420 aud1lc =aud0lc+16
  34. 430 aud1len=aud0len+16
  35. 440 aud1per=aud0per+16
  36. 450 aud1vol=aud0vol+16
  37. 460 :
  38. 470 REMark Find some chip memory
  39. 480 MaxVoice=32
  40. 490 chipx=ALCHP(MaxVoice)
  41. 500 fast_ram=(chipx>=chip_top)
  42. 510 IF fast_ram
  43. 520   RECHP chipx
  44. 530   REMark Use the spare Qdos chip RAM bytes
  45. 540   chipx=98688:REMark Guaranteed to be free
  46. 550   REMark Grab workspace after Qdos tables?
  47. 560   REMark This is incompatible with MMU use
  48. 570   REMark chipx=PEEK_L(SYSBASE+124)
  49. 580 END IF 
  50. 590 REMark Prepare four simple wave tables
  51. 600 RESTORE 
  52. 610 DATA -126,-90,-54,-18,18,54,90,126
  53. 620 DATA 127,127,127,127,-127,-127,-127,-127
  54. 630 DATA 0,90,127,90,0,-90,-127,-90
  55. 640 DATA 0,127,0,-127,63,-63,32,-32
  56. 650 FOR i=chipx TO chipx+MaxVoice-1
  57. 660   READ x : POKE i,x
  58. 670 END FOR i
  59. 680 voice=16
  60. 690 :
  61. 700 POKE_L aud0lc,chipx+voice
  62. 710 POKE_L aud1lc,chipx+voice
  63. 720 POKE_W aud0len,4
  64. 730 POKE_W aud1len,4
  65. 740 POKE_W aud0per,789
  66. 750 POKE_W aud1per,789
  67. 760 POKE_W aud0vol,64
  68. 770 POKE_W aud1vol,64
  69. 780 POKE_W adkcon,255 :REMark No modulation
  70. 790 :
  71. 800 HELLO : POINTER
  72. 810 AUDIO_ON 1+2 : cutoff=0
  73. 820 REPeat sing
  74. 830   POKE_W aud0per,note%(PTR_X% DIV 6)
  75. 840   POKE_W aud1per,note%(PTR_Y% DIV 6)
  76. 850   k$=INKEY$ : IF k$=" " : EXIT sing
  77. 860   IF k$="#" : cutoff=NOT cutoff : FILTER cutoff
  78. 870   IF k$="+" OR k$="-"
  79. 880     IF k$="+" : voice=(voice+8) MOD MaxVoice
  80. 890     IF k$="-" : voice=(voice-8) MOD MaxVoice
  81. 900     POKE_L aud0lc,chipx+voice
  82. 910     POKE_L aud1lc,chipx+voice
  83. 920   END IF 
  84. 930 END REPeat sing
  85. 940 AUDIO_OFF 1+2
  86. 950 IF NOT fast_ram : RECHP chipx
  87. 960 CLS #0 : PTR_OFF
  88. 970 STOP
  89. 980 :
  90. 990 DEFine PROCedure POINTER
  91. 1000 PTR_LIMITS 0,0,239,239
  92. 1010 PTR_POS 120,120
  93. 1020 PTR_INC 1,1 : PTR_ON
  94. 1030 END DEFine POINTER
  95. 1040 :
  96. 1050 DEFine PROCedure HELLO
  97. 1060 REMark Display note grid
  98. 1070 OPEN #3,scr_480x240a0x0 : CLS #3
  99. 1080 FOR j=6 TO 239 STEP 6
  100. 1090   pen=3 + ((j MOD 30)=18)
  101. 1100   BLOCK #3,2,240,j*2,0,pen
  102. 1110   BLOCK #3,480,1,0,j,pen
  103. 1120 END FOR j
  104. 1130 REMark Overlay instructions
  105. 1140 CSIZE #3,2,1 : OVER #3,-1 : INK #3,7
  106. 1150 PRINT #3,\," AMIGA QDOS SOUND DEMO 2"\\
  107. 1160 INK #3,4 : OVER #3,1
  108. 1170 PRINT #3;" Move the mouse to play a stereo sample"
  109. 1180 PRINT #3;" Keys +/- alter timbre # toggles filter"\\
  110. 1190 PRINT #3;"    Top left gives highest pitches"
  111. 1200 PRINT #3;"    Bottom right for lowest pitches"\\
  112. 1210 PRINT #3;" Press  SPACE  for silent SuperBASIC..."
  113. 1220 CLOSE #3
  114. 1230 END DEFine HELLO
  115. 1240 :
  116. 1250 DEFine PROCedure AUDIO_ON(x)
  117. 1260 REMark X =1, 2, 4, 8 for channels 1-4 on
  118. 1270 IF x>0 AND x<16
  119. 1280   POKE_W DMACONx,x-32768
  120. 1290 END IF 
  121. 1300 END DEFine AUDIO_ON
  122. 1310 :
  123. 1320 DEFine PROCedure AUDIO_OFF(c)
  124. 1330 REMark Turn off audio channels 1.2.4,8 only
  125. 1340 IF 1<=c AND c<=15
  126. 1350   POKE_W DMACONx,c
  127. 1360 END IF 
  128. 1370 END DEFine AUDIO_OFF
  129. 1380 :
  130. 1390 DEFine PROCedure FILTER(f)
  131. 1400 IF f
  132. 1410   POKE pra,PEEK(pra) && 253
  133. 1420 ELSE 
  134. 1430   POKE pra,PEEK(pra) || 2
  135. 1440 END IF 
  136. 1450 END DEFine FILTER
  137.